<?php

class Db_Tables_SysParams extends Zend_Db_Table
{
    protected $_name = 'sys-params';
	
	function GetVal($pkey)
	{
		$data = $this->fetchRow("pkey='".$pkey."'");
		
		if($data)
		{
			$result = $data['pval'];
		}else{
			$result = NULL;
		}
		
		return $result;
	}
	
	function BaseInfo()
	{
		$val = array(
			'site_name',
			'news_switch',
			'news_contents'
		);
		
		$select = $this->select();
		$select->where("pkey IN (?)", $val);
		$rows = $this->fetchAll($select);
		
		$result = array();
		
		if($rows)
		{
			foreach($rows as $row)
			{
				$result[$row['pkey']] = $row['pval'];
			}
		}
		
		return $result;
	}
	
	function YtxInfo()
	{
		$keys = array(
			'ytx-accountSid',
			'ytx-accountToken',
			'ytx-appId',
			'ytx-phoneVerify-tempId'
		);
		
		$select = $this->select();
		$select->where("pkey IN (?)", $keys);
		$rows = $this->fetchAll($select);
		
		$result = array();
		
		foreach($rows as $rval)
		{
			$result[$rval['pkey']] = $rval['pval'];
		}
		
		return $result;
	}
}